#!/bin/bash

# 自定义变量
title="Zenkilan's Knowledge Base"
description="Zenkilan's knowledge base"
theme="vue"

# 检查是否已经存在 docs 目录
if [ -d "docs" ]; then
  echo "The 'docs' directory already exists. Remove it..."
  rm -rf docs
fi

# 创建 docs 目录
echo "Creating 'docs' directory..."
mkdir -p docs

# 生成 index.html
chmod +x tools/generate-index.js
node tools/generate-index.js \
  --title "$title" \
  --description "$description" \
  --theme "$theme"

# 生成侧边栏和复制文件
chmod +x tools/generate-sidebar.js
node tools/generate-sidebar.js
echo "Documentation initialized successfully!"

# 启动文档预览服务器
echo "Run 'docsify serve docs' to preview the documentation."
cd docs && docsify serve